public class RotatePolygon implements Action{
  Polygon p;
  float initX,initY;
  float pX,pY;
  public RotatePolygon(Polygon p){
    this.p = p;
  }
  
 public void mouseDrag(float x, float y) {
    float dx = x-initX;
    float dy = y-initY;
    this.p.rotate(0.1*atan(dy/dx),this.p.getPoint(0));
    initX = x;
    initY = y;
  }

  public void mouseClick(float x, float y) {
  }

  void mousePress(float x, float y) {
    pX = this.initX = x;
    pY = this.initY = y;
  }
  void mouseMove(float x, float y) {
  }
}
